// +build !go1.7

package errors

import (
	"fmt"
	"runtime"
	"strings"
)

func getCallers(pcs []uintptr) string {
	var (
		invalid bool
		callers string
	)
	for ii, pc := range pcs {
		fn := runtime.FuncForPC(pc)
		if fn != nil {
			file, line := fn.FileLine(pc)
			index := strings.Index(file, "xp/")
			if index > 0 {
				invalid = false
				for _, ignore := range ignorePrefix {
					if strings.HasPrefix(file[index+4:], ignore) {
						invalid = true
						break
					}
				}
				if invalid {
					continue
				}
				if ii != 0 {
					callers += ","
				}
				callers += fmt.Sprintf("%s:%d", file[index+4:], line)
			}
		}
	}
	return callers
}
